//
// Created by Mengyu Li on 2021/3/10.
//

import Foundation
import LMDB

public protocol PrimitiveStorable: Storable {
    associatedtype Value: DataConvertible
    var value: Value { get }
    init(value: Value)
}

public extension PrimitiveStorable {
    init?(data: Data) {
        guard let value = Value(data: data) else { return nil }
        self.init(value: value)
    }

    var toData: Data { value.toData }
}
